﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using WSAP;

namespace BeamLoad
{
    public partial class BeamLoadForm : Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public BeamLoadForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 梁截面宽度
        /// </summary>
        private double beamWidth
        {
            get
            {
                return Convert.ToDouble(this.BeamWidthTextbox.Text);
            }
        }

        /// <summary>
        /// 梁截面高度
        /// </summary>
        private double beamHeight
        {
            get
            {
                return Convert.ToDouble(this.BeamHeightTextbox.Text);
            }
        }

        /// <summary>
        /// 刚域长度
        /// </summary>
        private double rigidEndLength
        {
            get
            {
                return this.BeamRigidEndCheckBox.Checked ?
                    Convert.ToDouble(this.BeamRigidEndTextbox.Text) : 0;
            }
        }

        /// <summary>
        /// 构件长度
        /// </summary>
        private double length
        {
            get
            {
                return Convert.ToDouble(this.LengthTextbox.Text);
            }
        }

        /// <summary>
        /// 获得单元荷载对象
        /// </summary>
        /// <returns></returns>
        private ElementLoadEnum GetElementLoadEnum()
        {
            if (this.PrtRadio.Checked) return ElementLoadEnum.FramePoint;
            else if (this.UniformRadio.Checked) return ElementLoadEnum.FrameUniform;
            else if (this.TriangularRadio.Checked) return ElementLoadEnum.FrameTriangular;
            else if (this.TrapezoidRadio.Checked) return ElementLoadEnum.FrameTrapezoid;
            else return ElementLoadEnum.FramePoint;
        }

        /// <summary>
        /// 显示荷载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DiagramButton_Click(object sender, EventArgs e)
        {
            switch(this.GetElementLoadEnum())
            {
                case ElementLoadEnum.FrameUniform:
                    WSAPBeamLoad.UniformLoad(this.beamWidth, this.beamHeight, this.length,
                        this.rigidEndLength,
                        Convert.ToDouble(this.ULoadTB.Text));
                    break;
                case ElementLoadEnum.FramePoint:
                    WSAPBeamLoad.PointLoad(this.beamWidth, this.beamHeight, this.length,
                         this.rigidEndLength,
                        Convert.ToDouble(this.PrtLoadTextbox.Text),
                        Convert.ToDouble(this.PrtDistTB.Text));
                    break;
                case ElementLoadEnum.FrameTriangular:
                    WSAPBeamLoad.TriangularLoad(this.beamWidth, this.beamHeight, this.length,
                         this.rigidEndLength,
                         Convert.ToDouble(this.TriLoadTB.Text),
                        Convert.ToDouble(this.TriDistTB.Text));
                    break;
                case ElementLoadEnum.FrameTrapezoid:
                    WSAPBeamLoad.TrapezoidLoad(this.beamWidth, this.beamHeight, this.length,
                         this.rigidEndLength,
                         Convert.ToDouble(this.TraLoadTB.Text),
                        Convert.ToDouble(this.TraDistTB1.Text),
                         Convert.ToDouble(this.TraDistTB2.Text));
                    break;
            }


        }
    }
}
